home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
- #include <tos.h>
-
- typedef struct
- { char firstchar[1];
- char start[5];
- char renew[5];
- char title[26];
- char name[28];
- char address[28];
- char citystate[21];
- char zip[6];
- char phone[8];
- char area[4];
- char group[2];
- char lastchar[1];
- }
- RECORD ;
-
- #define RECORDLEN sizeof(RECORD)
-
- static RECORD record, emptyrecord;
-
- static int currentdate;
-
-
- void seteoss(char* cp);
- void printrecord(RECORD record);
- void whatdate(void);
- int main(void);
-
-
- void seteoss(char* cp)
- {
- cp += 5; *cp = '\0';
- cp += 5; *cp = '\0';
- cp += 26; *cp = '\0';
- cp += 28; *cp = '\0';
- cp += 28; *cp = '\0';
- cp += 21; *cp = '\0';
- cp += 6; *cp = '\0';
- cp += 8; *cp = '\0';
- cp += 4; *cp = '\0';
- cp += 2; *cp = '\0';
- }
-
-
- void printrecord(RECORD record)
- {
- char groups[7]="SMBsmb";
- int i, linecount, expdate;
-
- linecount=0;
-
- expdate= record.renew[0]-(int) '0';
- expdate=10*expdate+record.renew[1]-(int) '0';
- expdate=10*expdate+record.renew[2]-(int) '0';
- expdate=10*expdate+record.renew[3]-(int) '0';
-
- for(i=19; ((i>1)&&(record.citystate[i-1]==' ')); i--);
- record.citystate[i]='\0';
-
- for(i=0;((groups[i]!=record.group[0])&&(groups[i++]!='\0')););
- i++;
- printf("%c!%c%cS%c",27,5,27,1);
- switch (i) {
- case 1: printf(" SPACE ");
- break;
- case 2: printf(" MAST ");
- break;
- case 3: printf(" SPACE/MAST ");
- break;
- default: printf(" ");
- break;
- }
- if (strcmp(emptyrecord.renew,record.renew)!=0) {
- printf("EXP %s",record.renew);
- if (expdate <currentdate) printf(" %c-%c<<You are past due!!>>%c-%c",27,1,27,0);
- if (expdate==currentdate) printf(" %c-%c<<Please renew now!!>>%c-%c",27,1,27,0);
- }
- printf("%cT%c!%c\n",27,27,3); linecount++;
-
- if (strcmp(emptyrecord.title,record.title)!=0) {
- printf("%s\n",record.title); linecount++;
- }
- if (strcmp(emptyrecord.name,record.name) !=0) {
- printf("%s\n",record.name); linecount++;
- }
- printf("%s\n",record.address); linecount++;
- printf("%s %s\n",record.citystate,record.zip); linecount++;
- while (linecount++<6) printf("\n");
- }
-
- void whatdate(void)
- {
- unsigned int i,day,month,year;
-
- i=Tgetdate();
- day=i&0x1f;
- month=(i>>5)&0x0f;
- year=((i>>9)&0x7f)+80;
- if (day>15) month++;
- if (month>12) {month=1; year++;}
- currentdate=year*100+month;
- }
-
-
- int main(void)
- {
- int i;
- char *cp;
-
- whatdate();
- memset(emptyrecord.firstchar,' ',RECORDLEN);
- memset(emptyrecord.renew,'9',4);
- seteoss((char *)emptyrecord.firstchar);
-
- for(i=0;((cp=gets(record.firstchar))!=NULL);i++) {
- seteoss(cp);
- printrecord(record);
- }
- return (0);
- }
-